<?php
/**
 * User: @lose
 * Date: 2020/7/28
 * Time: 2:02 下午
 */

namespace Beerus\Modules\BlackCard\Controllers;

use App\Http\Controllers\Controller;
use App\Pockets\GridDataModel as pGridDataModel;
use Doraemon\service\BlackCard\BlackUser;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use Encore\Admin\Grid;
use Illuminate\Http\Request;
use Biz\model\wiki\Wiki as mWiki;
use Doraemon\service\BlackCard\AdminWiki as sAdminWiki;

class UserController extends Controller
{
    public function index(Content $content, Request $request)
    {
        $page = $request->input('page', 1);
        $perPage = $request->input('per_page');

        $limit = [
            ($page - 1) * $perPage, $perPage
        ];

        $result = BlackUser::getList($limit);
        $grid = new pGridDataModel($result['list'], $result['total'], [
            'per_page' => $perPage
        ]);

        $gridList = Admin::grid($grid,
            function (Grid $grid) {
                $grid->disableExport();
                $grid->disableRowSelector();
                $grid->disableCreateButton();
                $grid->disableFilter();

                $grid->column("id", 'id');
                $grid->column("uid", '用户uid');
                $grid->column('link', 'app返佣')->display(function () {
                    return "<a href=\"https://shop-admin.haohaozhu.me/admin/salesRebate/orders?step=1&uid={$this->uid}&nick=&telephone=&type=&order_no=&start_time=&end_time=\" target='_blank' >查看APP返佣记录</a>";
                });
                $grid->column("nick", '用户昵称');
                $grid->column("black_no", '黑卡会员号');
                $grid->column("withdrawal_amount", '当前可提现金额');
                $grid->column("total_withdrawal_amount", '累积申请提现金额');
                $grid->column("username", '云账户姓名');
                $grid->column("telephone", '手机号');
//                ''
                $grid->column("cloud_no", '云账户账号');
                $grid->disableActions();
            });

        $content->row($gridList);
        return $content
            ->header('黑卡小程序用户')
            ->description(' ')
            ->breadcrumb(['text' => 'user']);
    }
}